import React, { PureComponent } from 'react';
import { connect } from 'dva';
import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
import 'moment/locale/zh-cn';
import ResultIndexC from '../components/resultC';
import SettingC from '../components/settingC';

@connect(({ portfolioOptimizationM, loading }) => ({
  portfolioOptimizationM,
  loading,
}))
@Form.create()
export default class BasicInfo extends PureComponent {
  state = {
    pageStatus: '1', // 1参数设置 2结果页
    typeStatus: '1', // 1新增 2编辑 3 查看
    id: undefined, // 参数id
  };

  componentDidMount() {}

  changeStatus = (e, type) => {
    this.setState({
      pageStatus: e,
    });
    if (type) {
      this.setState({
        typeStatus: '1',
        id: undefined,
      });
    }
    this.props.dispatch({
      type: 'portfolioOptimizationM/setState',
      payload: {
        isShowTitle: e == 1,
      },
    });
  };

  render() {
    const { type } = this.props;
    const { pageStatus, typeStatus, id } = this.state;

    return (
      <div>
        {pageStatus == 1 && <SettingC typeStatus={typeStatus} type={type} changeStatus={this.changeStatus} id={id} />}
        {pageStatus == 2 && (
          <ResultIndexC
            changeStatus={this.changeStatus}
            changeType={(e, type) => {
              this.setState({
                typeStatus: type,
                id: e,
              });
            }}
            fromBarra={false}
            id={id}
            type={type}
          />
        )}
      </div>
    );
  }
}
